﻿@using VideoSeller.Business.Data.Enums
@model RecommendedViewModel

@{
	var curentContentId = -1;
	if (ViewContext.RouteData.Values["controller"] != null && ViewContext.RouteData.Values["controller"].ToString().ToLower() == "home" &&
	    ViewContext.RouteData.Values["action"] != null && ViewContext.RouteData.Values["action"].ToString().ToLower() == "content") {
		curentContentId = ViewContext.RouteData.Values["id"] != null ? int.Parse(ViewContext.RouteData.Values["id"].ToString()) : -1;
	}

	var hasRecommended = curentContentId != -1 && Model.Items.Any(x => x.Id == curentContentId);
	var slSet = false;
}

<div id="recomended">
	<div class="rt">@Html.GetGlobalResource("Common", "Recomended")</div>
	<ul>
		@for (var i = 0; i < Model.Items.Count; i++) {
			var value = string.Empty;

			if (hasRecommended) {
				if (Model.Items[i].Id == curentContentId) {
					value = "sc";
				}
				else {
					value = slSet ? "sr" : "sl";
					slSet = value == "sl";
				}
			}
			else {
				value = i == 0 ? "sc" : (i == 1 ? "sr" : "sl");
			}

			<li id="@value">
				<a href="@Url.Action("Content", "Home", new { id = Model.Items[i].Id })">
					<img src="@Url.GetThumbnailImage(Model.Items[i].ImageUrl, ThumbnailImageSize.Small)" alt="">
				</a>
			</li>
		}
	</ul>
	<a class="tleft" onclick="sleftclick()"><img src="@Url.Content("~/Content/images/blank.gif")"></a>
	<a class="tright" onclick="srightclick()"><img src="@Url.Content("~/Content/images/blank.gif")"></a>
</div>